package domain.entities.impl;

import java.util.Set;

import domain.entities.interfaces.IAddress;
import domain.entities.interfaces.IContact;
import domain.entities.interfaces.IContactGroup;
import domain.entities.interfaces.IPhoneNumber;


public class Contact implements IContact {
	private String firstName;
	private String lastName;
	private String email;
	private int id;
	private IAddress add;
	private Set<IPhoneNumber> phones;
	private Set<IContactGroup> books;
	private int version;
	private int childsVersion;



	public int getVersion() {
		return version;
	}

	public void setVersion(int version) {
		this.version = version;
	}
	/* (non-Javadoc)
	 * @see domain.entities.impl.IContact#getBooks()
	 */
	public Set<IContactGroup> getBooks() {
		return books;
	}

	/* (non-Javadoc)
	 * @see domain.entities.impl.IContact#setBooks(java.util.Set)
	 */
	public void setBooks(Set<IContactGroup> books) {
		this.books = books;
	}

	/* (non-Javadoc)
	 * @see domain.entities.impl.IContact#getPhones()
	 */
	public Set<IPhoneNumber> getPhones() {
		return phones;
	}

	/* (non-Javadoc)
	 * @see domain.entities.impl.IContact#setPhones(java.util.Set)
	 */
	public void setPhones(Set<IPhoneNumber> phones) {
		this.phones = phones;
	}

	/* (non-Javadoc)
	 * @see domain.entities.impl.IContact#getAdd()
	 */
	public IAddress getAdd() {
		return add;
	}

	/* (non-Javadoc)
	 * @see domain.entities.impl.IContact#setAdd(domain.entities.impl.IAddress)
	 */
	public void setAdd(IAddress add) {
		this.add = add;
	}

	public Contact() {
		super();
	}

	/* (non-Javadoc)
	 * @see domain.entities.impl.IContact#getFirstName()
	 */
	public String getFirstName() {
		return firstName;
	}
	/* (non-Javadoc)
	 * @see domain.entities.impl.IContact#setFirstName(java.lang.String)
	 */
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}
	/* (non-Javadoc)
	 * @see domain.entities.impl.IContact#getLastName()
	 */
	public String getLastName() {
		return lastName;
	}
	/* (non-Javadoc)
	 * @see domain.entities.impl.IContact#setLastName(java.lang.String)
	 */
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
	/* (non-Javadoc)
	 * @see domain.entities.impl.IContact#getEmail()
	 */
	public String getEmail() {
		return email;
	}
	/* (non-Javadoc)
	 * @see domain.entities.impl.IContact#setEmail(java.lang.String)
	 */
	public void setEmail(String email) {
		this.email = email;
	}
	/* (non-Javadoc)
	 * @see domain.entities.impl.IContact#getId()
	 */
	public int getId() {
		return id;
	}
	/* (non-Javadoc)
	 * @see domain.entities.impl.IContact#setId(int)
	 */
	public void setId(int id) {
		this.id = id;
	}

	/* (non-Javadoc)
	 * @see domain.entities.impl.IContact#removeContactGroup(int)
	 */
	public void removeContactGroup(int idContactGroup) {
		IContactGroup toRemove = null;

		for(IContactGroup cg : books) {
			if(cg.getGroupId() == idContactGroup) {
				toRemove = cg;
				break;
			}
		}

		if(toRemove != null) {
			books.remove(toRemove);
		}
	}

	public int getChildsVersion() {
		return childsVersion;
	}

	public void setChildsVersion(int childsVersion) {
		this.childsVersion = childsVersion;
	}
}
